import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: Home,
    Fchildren:[
      {
        path: '/home/children',
        name: 'children',
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
      }
    ]
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

let relRoutes = []
routes.map(route=>{
  const {Fchildren,...rest} = route
  relRoutes.push(rest)
  if(Fchildren){
    relRoutes = relRoutes.concat(Fchildren)
  }
})


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes:relRoutes
})

export default router
